// by Xeno
#define __ctrl(vctrl) _ctrl = _XD_display displayCtrl vctrl
private ["_ctrl","_ok","_units","_index","_XD_display"];
if (!X_Client) exitWith {};

disableSerialization;

_ok = createDialog "XD_HaloDialog";

_XD_display = uiNameSpace getVariable "D_HALO_DIALOG";

_units = list D_AI_HUT_TRIGGER;
diag_log Format["(%1)[%2]: %3: %4",diag_tickTime,"halorequest.sqf","Start",[_units,D_AI_HUT_TRIGGER]];
__ctrl(21002);
lbClear 21002;
{
	if (isplayer _x) then {
		_index = _ctrl lbAdd (name _x);
		diag_log Format["(%1)[%2]: %3: %4",diag_tickTime,"halorequest.sqf","Adding",[(name _x),_index]];
	};
} forEach _units;
_ctrl lbSetCurSel 0;

D_HALO_MAP_POSITION = [0,0,0];
_mrk = ["d_ai_halo_request_marker", [0,0,0], "ICON", "ColorBlue", [0.6,0.6],localize "STR_DIAG_HALO_DESTINATION",0,"hd_flag","",0.0000000001] call XfCreateMarkerLocal;
onMapSingleClick "'d_ai_halo_request_marker' setMarkerPosLocal _pos; 'd_ai_halo_request_marker' setMarkerAlphaLocal 0.8; D_HALO_MAP_POSITION = _pos;";
waitUntil { !dialog || !alive player};
onMapSingleClick "";
deleteMarkerLocal _mrk;

if (!alive player) then {closeDialog 0};